﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ResourcesManagement;
using System.Globalization;
using System.Runtime.Serialization;

namespace YasharEl.Infrastructure.ProcessEngine
{
    [Serializable]
    public class ProcessDefinitionNotFoundException : TranslatedDomainModelException
    {
        private const string ProcessDefinitionNotFound = "ProcessDefinitionNotFound";

        private readonly long _processDefinitionId;

        public long RequestedProcessDefinitionId
        {
            get { return _processDefinitionId; }
        }

        public ProcessDefinitionNotFoundException(IResourceManager resourceManager, long processDefinitionId)
            : base
             (
                resourceManager,
                string.Format
                (
                    resourceManager.GetString(ProcessDefinitionNotFound, CultureInfo.GetCultureInfo("en")),
                    processDefinitionId
                )
             )
        {
            _processDefinitionId = processDefinitionId;
        }

        protected ProcessDefinitionNotFoundException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        protected override string ExceptionMessageResourceKey
        {
            get { return ProcessDefinitionNotFound; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ExceptionMessageResourceKey), RequestedProcessDefinitionId);
            }
        }
    }
}
